package cn.yj;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * @author 永健
 * @since 2022-02-09 09:51
 */
@SpringBootApplication
@EnableScheduling
public class PApp {
    public static void main(String[] args) {
        SpringApplication.run(PApp.class, args);
    }

    @Resource
    RabbitTemplate mq;

    @Scheduled(cron="*/5 * * * * ?")
    @PostConstruct
    public void send() {
        for (int i = 0; i < 10; i++) {
            mq.convertAndSend("ORDER_EXCHANGE", "order_no_key", ""+i);
        }
    }

}
